﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;

namespace ICDA.Web.Models
{
    public class CustomSearchViewModel
    {
        #region Properties
        public string UserID { get; set; }

        public string Name { get; set; }

        public int? ActivityDate { get; set; }

        public int? Task { get; set; }
        #endregion

        #region Methods
        public string GetFilterExpression()
        {
            StringBuilder filterExpressionBuilder = new StringBuilder();
            if (!String.IsNullOrWhiteSpace(UserID))
                filterExpressionBuilder.Append(String.Format("UserID = {0} AND ", UserID));
            if (!String.IsNullOrWhiteSpace(Name))
                filterExpressionBuilder.Append(String.Format("Name = \"{0}\" AND ", Name));
            if (ActivityDate.HasValue)
                filterExpressionBuilder.Append(String.Format("ActivityDate = {0} AND ", ActivityDate));
            if (Task.HasValue)
                filterExpressionBuilder.Append(String.Format("Task = {0} AND ", Task));
            if (filterExpressionBuilder.Length > 0)
                filterExpressionBuilder.Remove(filterExpressionBuilder.Length - 5, 5);
            return filterExpressionBuilder.ToString();
        }
        #endregion
    }
}